package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	runround
*/
public class runround {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("runround.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"runround.out")));
		new runround().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		int N = read(f);
		while (true) {
			N++;
			if (isRunAround(N)) break;
		}
		out.println(N);
	}
	
	private boolean isRunAround(int n) {
		String s = "" + n;
		int L = s.length();
		int count = 0;
		
		int[] a = new int[L];
		boolean[] visited = new boolean[10];
		for (int i=0; i<L; i++) {
			a[i] = s.charAt(i) - '0';
			if (visited[a[i]]) return false;
			visited[a[i]] = true;
		}
		
		int index = 0;
		for (int i=0; i<L; i++) {
			index = (index + a[index]) % L;
			count |= 1<<index;
		}
		
		return count+1 == 1<<L;
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	public int[] read(BufferedReader f, int N) throws IOException {
		String[] t = f.readLine().split(" ");
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
}
